function bucketSort(array) {
    //1.得到数列的最大值和最小值，并计算差值
    let max = Math.max(...array);
    let min = Math.min(...array);
    let d =max-min;
    //2.初始化桶
    let bucketNum = array.length;
    let bucketArray = new Array(bucketNum)
    for(let i=0;i<bucketNum;i++){
        bucketArray[i]=[]
    }
    //3.遍历原始数组，将每个元素放入对应的桶中
    for(let i=0;i<array.length;i++){
        let index = Math.floor((array[i] - min) * (bucketNum - 1) / d)
        console.log('index',index)
        console.log('array[i]',array[i])
        bucketArray[index].push(array[i]);
    }
    //4.对每个桶进行排序
    for(let i=0;i<bucketNum;i++){
        bucketArray[i].sort((a,b)=>{
            return a-b;
        })
    }
    console.log(bucketArray)
    //5.将每个桶中的元素放入原始数组中
    let result=[]
    for(let i=0;i<bucketNum;i++){
        for(let j=0;j<bucketArray[i].length;j++){
            result.push(bucketArray[i][j]);
        }
    }
    return result
}

let arr1=[4.12,6.421,0.0023,3.123,3.5,1.23,2.34,5.67,7.89,1.24]
console.log(bucketSort(arr1))